package cn.gson.springboot.model.service;

import cn.gson.springboot.model.dao.InvoiceRecordDao;
import cn.gson.springboot.model.mapper.InvoiceRecordMapper;
import cn.gson.springboot.model.pojos.InvoiceRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class InvoiceRecordService {
    @Autowired
    InvoiceRecordMapper invoiceRecordMapper;
    @Autowired
    InvoiceRecordDao invoiceRecordDao;
    /*public List<InvoiceRecord> selectEmpInvoiceRecord(Integer deptId){
        return invoiceRecordMapper.selectEmpInvoiceRecord(deptId);
    }*/

    public List<InvoiceRecord> selectEmpInvoiceRecordByType(Integer deptId, Integer invoicerecordType) {
        return invoiceRecordMapper.selectEmpInvoiceRecordByType(deptId,invoicerecordType);
    }

    public List<InvoiceRecord> selectEmpInvoiceRecordByBack(Integer deptId, Integer invoicerecordBack) {
        return invoiceRecordMapper.selectEmpInvoiceRecordByBack(deptId,invoicerecordBack);
    }

    public List<InvoiceRecord> selectEmpInvoiceRecordByDate(Integer deptId, String invoicerecordDate) {
        return  invoiceRecordMapper.selectEmpInvoiceRecordByDate(deptId,invoicerecordDate);
    }

    public List<InvoiceRecord> selectEmpInvoiceRecordByNumber(Integer deptId, String invoicerecordNo) {
        return invoiceRecordMapper.selectEmpInvoiceRecordByNumber(deptId,invoicerecordNo);
    }

    public List<InvoiceRecord> selectEmpInvoiceRecordByCusName(Integer deptId, String customerName) {
        return invoiceRecordMapper.selectEmpInvoiceRecordByCusName(deptId,customerName);
    }

    @Transactional(transactionManager = "transactionManager")
    public void saveInvoiceRecord(InvoiceRecord invoiceRecord) {
        invoiceRecordDao.save(invoiceRecord);
    }

    @Transactional(transactionManager = "transactionManager")
    public void deleteInvoiceRecord(Integer invoicerecordId) {
        invoiceRecordDao.deleteById(invoicerecordId);
    }

    public List<InvoiceRecord> selectBackInvoiceByConId(Integer conId) {
        return invoiceRecordMapper.selectBackInvoiceByConId(conId);
    }

    public List<InvoiceRecord> selectEmpInvoiceRecord(int deptId, int empId, Integer value, Integer num, Integer vague, String content) {
        return invoiceRecordMapper.selectEmpInvoiceRecord(deptId,empId,value,num,vague,content);
    }
}
